#pragma once
#include "..\Lexer\Lexer.h"
#include "NV.h"
#include "Syntax.h"

class Third
{
public:
	int one;
	int two;
	int three;

	Third(int o,int t,int th) : one(o),two(t),three(th){}
};

class Pair
{
public:
	int one;
	int two;

	Pair(int o,int t) : one(o),two(t){}
};

class NParser
{
public:
	List<NAutoPtr<Pair>> pTable;

	NParser(int Size);
	BOOL AddVn(NAutoPtr<NV>* Chars,int Size);
	BOOL AddVt(NAutoPtr<NV>* Chars,int Size);
	BOOL SetP(List<NAutoPtr<Precept>> L);
	void SetStart(int v);
	BOOL Parser(List<NAutoPtr<NToken>>& Tokens);
	NWString GetError();
	int GetErrorLine();
protected:
	List<NAutoPtr<NV>> Vn;
	List<NAutoPtr<NV>> Vt;
	List<NAutoPtr<Precept>> P;
	List<NAutoPtr<Regex>> RegexList;
	int vStart;
	int nVn;
	int nVt;
	int nP;
	int nLine;
	NSyntax Syntax;

	NAutoPtr<NV> Char_$;
	NAutoPtr<NV> Char_End;
	NAutoPtr<NV> Char_Empty;
	NAutoPtr<NV> Char_Point;
	int n_$;
	int n_End;
	int n_Empty;
	int n_Point;

	Third* LoadParserTable();
	int FindVn(int Char);
	int FindVt(NWString& String);
	NAutoPtr<Pair> GetAction(int Status,NAutoPtr<NToken>& Token,int Pos);
	int GetGoTo(int Status,int Char);
};
